package com.slz3.business.module.goodsManagement.gooAttribute.steward;

import com.slz3.business.frame.response.RR;
import com.slz3.business.frame.response.ResInfo;
import com.slz3.business.module.goodsManagement.gooAttribute.domain.GooAttribute;
import com.slz3.business.module.goodsManagement.gooAttribute.domain.GooAttributeCondition;
import org.springframework.stereotype.Controller;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

@Controller
public class GooAttributeResController {

    @Resource
    private GooAttributeResAtomic gooAttributeResAtomic;

    public Mono<ServerResponse> add(ServerRequest req, GooAttribute gooAttribute) {
        if (GooAttributeResUnsafeValid.add(req, gooAttribute)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooAttributeResAtomic.add_$GooAttributeUpdateLock(req, gooAttribute);
        }
    }

    public Mono<ServerResponse> delete(ServerRequest req, GooAttributeCondition gooAttributeCondition) {
        if (GooAttributeResUnsafeValid.delete(req, gooAttributeCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooAttributeResAtomic.delete_$GooAttributeUpdateLock(req, gooAttributeCondition);
        }
    }

    public Mono<ServerResponse> modify(ServerRequest req, GooAttribute gooAttribute) {
        if (GooAttributeResUnsafeValid.modify(req, gooAttribute)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooAttributeResAtomic.modify_$GooAttributeUpdateLock(req, gooAttribute);
        }
    }

    public Mono<ServerResponse> list(ServerRequest req) {
        if (GooAttributeResUnsafeValid.list(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return GooAttributeResExecutor.list(req);
        }
    }

    public Mono<ServerResponse> info(ServerRequest req) {
//        return gooAttributeResAtomic.info_$GooAttributeUpdateLock(req);
        if (GooAttributeResUnsafeValid.info(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooAttributeResAtomic.info_$GooAttributeUpdateLock(req);
        }
    }

    public Mono<ServerResponse> choice(ServerRequest req) {
        if (GooAttributeResUnsafeValid.choice(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return GooAttributeResExecutor.choice(req);
        }
    }

    public Mono<ServerResponse> auditSubmit(ServerRequest req, GooAttributeCondition gooAttributeCondition) {
        //
        if (GooAttributeResUnsafeValid.auditSubmit(req, gooAttributeCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooAttributeResAtomic.auditSubmit_$GooAttributeUpdateLock(req, gooAttributeCondition);
        }
    }

    public Mono<ServerResponse> audit(ServerRequest req, GooAttributeCondition gooAttributeCondition) {
        if (GooAttributeResUnsafeValid.audit(req, gooAttributeCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooAttributeResAtomic.audit_$GooAttributeUpdateLock(req, gooAttributeCondition);
        }
    }

    public Mono<ServerResponse> auditReject(ServerRequest req, GooAttributeCondition gooAttributeCondition) {
        if (GooAttributeResUnsafeValid.auditReject(req, gooAttributeCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooAttributeResAtomic.auditReject_$GooAttributeUpdateLock(req, gooAttributeCondition);
        }
    }

    public Mono<ServerResponse> usingEnable(ServerRequest req, GooAttributeCondition gooAttributeCondition) {
        if (GooAttributeResUnsafeValid.usingEnable(req, gooAttributeCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooAttributeResAtomic.usingEnable_$GooAttributeUpdateLock(req, gooAttributeCondition);
        }
    }

    public Mono<ServerResponse> usingDisable(ServerRequest req, GooAttributeCondition gooAttributeCondition) {
        if (GooAttributeResUnsafeValid.usingDisable(req, gooAttributeCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooAttributeResAtomic.usingDisable_$GooAttributeUpdateLock(req, gooAttributeCondition);
        }
    }

}
